SHELL=cmd.exe
SRC = $(wildcard *.c)
OBJ = $(SRC:%.c=%.o)
ENCODING = -fexec-charset=gbk -finput-charset=UTF-8
ifdef TOOLCHAIN # ifdef 语句用来判断变量TOOLCHAIN 是否有定义
	CC = $(TOOLCHAIN)
else
	CC = gcc
endif
image: $(OBJ)
ifeq ($(CC), gcc)
	$(CC) $^ -o $@ -lgcc $(ENCODING)
else
	$(CC) $^ -o $@ $(ENCODING)
endif
$(OBJ): %.o: %.c
	$(CC) $^ -o $@ -c $(ENCODING)
.PHONY: clean
clean:
	$(RM) $(OBJ)